#!/usr/bin/env python
# encoding: utf-8

"""
@version: python3.7
@Author  : huangyi
@contact:  hy.dazui@qq.com
@Time    : 2020/1/12 23:30
@Describe: add Describe here
"""
from ...scanner.token.token import TokenType, NumberToken, OpToken, LeftBracket, RightBracket, PointToken, FuncToken, \
    CommaToken, StringToken, VarToken


class TokenFactory:

    @classmethod
    def build_token(cls, toke_type: TokenType, data):
        if toke_type == TokenType.NUMBER:
            return NumberToken(data)
        elif toke_type == TokenType.OP:
            return OpToken(data)
        elif toke_type == TokenType.POINT:
            return PointToken(data)
        elif toke_type == TokenType.LEFT_BRACKET:
            return LeftBracket(data)
        elif toke_type == TokenType.RIGHT_BRACKET:
            return RightBracket(data)
        elif toke_type == TokenType.FUNC:
            return FuncToken(data)
        elif toke_type == TokenType.COMMA:
            return CommaToken(data)
        elif toke_type == TokenType.STRING:
            return StringToken(data)
        elif toke_type == TokenType.VAR:
            return VarToken(data)
        else:
            raise Exception("error type: {}".format(toke_type))
